<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .box {
            width: 200px;
            height: 200px;
            background-color: aquamarine;
            margin: 50px;
            overflow: hidden;
        }
        .sub{
            width: 100px;
            height: 100px;
            background-color: orange;
            margin: 50px;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="sub"></div>
    </div>
</body>
<script>
    // 鼠标相关的事件



    var box = document.querySelector(".box");


    // onmouseover  鼠标移入
    // onmouseout  鼠标移出

    // onmouseover onmouseout的问题:
    // 给父元素绑的onmouseover onmouseout,划入子(代)元素时,会先触发移出,再出发移入

    // 怎么解决?
    // 使用onmouseenter onmouseleave 替换  onmouseover onmouseout


    // box.onmouseover = function(){
    //     console.log("鼠标移入");
    // }

    // box.onmouseout = function(){
    //     console.log("鼠标移出");
    // }

    box.onmouseenter = function(){
        console.log("鼠标移入");
    }

    box.onmouseleave = function(){
        console.log("鼠标移出");
    }



</script>

</html>